﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.util.*"%> 
<!doctype html>
<html lang="en">
<head>
	<title>宿舍在线签到系统</title>
</head>
<style>
*{
text-align:center;
margin-top:20px;
}
</style>
<body bgcolor="darkorange">
	<%!
	Vector<String> userList=new Vector<String>();
	%>

	<form action="attend.jsp">
			<p/>请输入你的名字:<input type="text" name="username"/>
			<p/><input type="submit" value="签到"/>
	</form>
	<%
		String username=request.getParameter("username");
		if(username==null||username.isEmpty()){
				//TODO
		}else{
				if(session.getAttribute("flag")==null){
				byte[] bb=username.getBytes("ISO-8859-1");
				username		=new String(bb,"UTF-8");
				if(!userList.contains(username))
						userList.add(username);
						session.setAttribute("flag",true);
			}
		}
	%>
	<p/>当前用户:<%=username%>
	<p/>共有<%=userList.size()%>在线:
	<table border="1" bgcolor="yellow">	
	<%
		Collections.sort(userList);
	int id=1;
		for(String user:userList)
			out.println(String.format("<tr><td>%02d</td><td>%s</td></tr>",id++,user));
	%>
	</table>
<a href="login.html">回头是岸</a>
	
</body>
</html>